<template>
  <div>
    <router-link tag="div" to="/" class="header-abs" v-show="ISshow"><span class="iconfont icon-abs">&#xe624;</span></router-link>
    <div class="header-fixd" v-show="!ISshow" :style="opacityStyle">
      <router-link class="a_back" to="/">
       <span class="iconfont fixd-back">&#xe624;</span>
      </router-link>
      景点详情
    </div>
  </div>
</template>

<script>
export default {
  name:'DetailHeader',
  data () {
    return {
      ISshow: true,
      opacityStyle: {
        opacity: 0
      }
    }
  },
  methods: {
    handleScroll () {
      const top = document.documentElement.scrollTop
      if (top > 40) {
        let opacity = top / 120
        opacity = opacity > 1 ? 1 : opacity
        this.opacityStyle = { opacity }
        this.ISshow = false
      }else{
        this.ISshow = true
      }
    }
  },
  activated () {
    window.addEventListener('scroll',this.handleScroll)
  },
  deactivated () {
    window.removeEventListener('scroll',this.handleScroll)
  }
}
</script>

<style lang="stylus" scoped>
.header-abs
  position absolute
  left .2rem
  top .2rem
  width .8rem
  height .8rem
  border-radius .4rem
  line-height .8rem
  text-align center
  background rgba(0,0,0,.5)
  .icon-abs
    color #ffffff
    font-size .4rem
.header-fixd
  position fixed
  top 0
  left 0
  right 0
  height .86rem
  line-height .86rem
  text-align center
  background #00bcd4
  color #fff
  .a_back
    color #ffffff
    .fixd-back
      position absolute
      top 0
      left 0
      width .64rem
      text-align center
</style>
